import 'package:flutter/material.dart';

class PreparePainter extends CustomPainter {
  late Paint _paint;
  late Path _path;

  PreparePainter() {
    _paint = Paint()
      ..color = Colors.blue
      //..isAntiAlias = true
      ..strokeWidth = 4
      ..style = PaintingStyle.stroke;//画笔类型，划线不适合用fill
    _path = Path();
  }
  @override
  void paint(Canvas canvas, Size size) {
    // TODO: implement paint
    print(size);
    canvas.drawLine(Offset(0,0), Offset(100,100), _paint);

    _path.moveTo(100, 100);//移动画笔的位置后的起始位置
    _path.lineTo(200, 300);//移动画笔后的结束位置
    canvas.drawPath(_path, _paint..color = Colors.green..strokeWidth = 20);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    // TODO: implement shouldRepaint
    return true;
  }
}
